package jsonError

import (
	"commons/enums/sysCode"
	"commons/handler/response"
)

func Write(code int, msg string, data interface{})(res response.Handle) {

	var _json response.Handle
	_json.Code = sysCode.Code.ERROR
	_json.Msg = sysCode.GetError(sysCode.Code.ERROR)
	_json.Data= ""
	if code != 0 {
		_json.Code = code
		_json.Msg = sysCode.GetError(code)
	}
	if msg != "" {
		_json.Msg = msg
	}
	if data != nil {
		_json.Data = data
	}
	//result, _ := json.Marshal(_json)
	//_, _ = response.Response.Write(result)
	return _json
}
